/**利用指针对三个数进行排列 从大到小
int main()
{
	int a,b,c,temp;
	int *p,*q,*k;
	printf("请输入三个整数：\n");
	scanf("%d%d%d",&a,&b,&c);
	p = &a;
	q = &b;
	k = &c;
	if(*p < *q)
	{
		temp = *p;
		*p = *q;
		*q = temp;
	}
	if(*k > *p)
	{
		temp = *p;
		*p = *k;
		*k = temp;
	}
	if(*k > *q)
	{
		temp = *q;
		*q = *k;
		*k = temp;
	}
	printf("由大到小排列为%d->%d->%d\n",a,b,c);
}

void swap(int *p2,int *q2)
{
	int temp;
	temp = *p2;
	*p2 = *q2;
	*q2 = temp;
}


void exchge(int *p1,int *q1,int *k1)
{

	if(*q1 > *p1)
	{
		swap(q1,p1);
	}                                    
	if(*k1 > *p1)
	{
		swap(k1,p1);
	}
	if(*k1 > *q1)
	{
		swap(k1,q1);
	}
}


int main()
{
	int a,b,c;
	int *p,*q,*k;
	printf("请输入三个整数：\n");
	scanf("%d%d%d",&a,&b,&c);
	p = &a;
	q = &b;
	k = &c;
	exchge(p,q,k);
	printf("由大到小排列为%d->%d->%d\n",a,b,c);
	puts("\n");
	getch();
}
***/
/***

#include<stdio.h>

#include"mseeage.h"

int main()
{
	struct student 	student1 = {1001,"liming",'M',20,98.5};
	struct student *p;
	p = &student1;
	printf("Number:%d\n",p->num);
	printf("Name:%d\n",p->name);
	printf("Sex:%d\n",p->sex);
	printf("Age:%d\n",p->age);
	printf("Score:%d\n",p->score);

}
#ifndef _MSEEAGE_H_
#define _MSEEAGE_H_

//#include<stdio.h>
struct student{
		int num;//
		char name[20];//
		char sex;//
		int age;
		float score;
};

#endif
***/

/**冒泡排序

#include<stdio.h>
int main()
{
	int a[10] = {6,2,3,4,5,14,7,8,9,10};
	int i,k,j,temp;
//	int max,min;
//	max_min(a,10,&max,&min);
	for(i = 0;i < 10;i++)
	{
		for(j = i+1;j<10;j++)
		{
			if(a[i] < a[j])
			{
				temp = a[i];
				a[i] = a[j];
				a[j] = temp;
			}
		}
		for(k = 0;k < 10;k++)
		{
			printf("%d->",a[k]);
		}
			printf("\n");
	}
	printf("\n");
	for(k = 0;k < 10;k++)
	{
		printf("%d->",a[k]);
	}
		printf("\n");

}

***/
/**
void max_min(int n,int a[],int *max,int *min)
{
	int *p;
	*max = *min = *a;
	for(p = a+1;p<a+n;p++)
	{
		if(*p > *max)
		{
			*max = *p;
		}
		if(*p < *min)
		{
			*min = *p;
		}
	}
}


int main()
{
	int a[10] = {6,2,3,4,5,14,7,8,9,10};
	int max,min;
	max_min(10,a,&max,&min);
	printf("max = %d->min = %d\n",max,min);
}
****/
/***
int main()
{
	char *str[] = {"陈dy","赵gao","lisan","laosi","wangwu"};
	char **p;
	int i;
	p = str;
	for(i = 0;i<5;i++)
	{
		printf("%s\n",*(p+i));
	}
}
*****/
/**
void sort(char *string[],int n)
{
	char *temp;
	int i,j;
	for(i = 0;i < n;i++)
	{
		for(j = i+1;j < n;j++)
		{
			if(strcmp(string[i],string[j]) > 0)
			{
				temp = string[i];
				string[i] = string[j];
				string[j] = temp;
			}
		}
	}
}

void main()
{
	int n = 5;
	int i;
	char **p;
	char *string[]={"赵XX","钱XX","孙XX","李XX","周XX"};
	p = string;
	printf("排序前的数组\n");
	for(i = 0;i<n;i++)
	{
		printf("%s\n",string[i]);
	}
	sort(p,n);
	printf("排序后的数组\n");
	for(i = 0;i<n;i++)
	{
		printf("%s\n",string[i]);
	}
	getch();
}
***/

/**找出最大值
int *found_max(int *a,int n)
{
	int *max,i;
	max = a;
	for(i = 0;i < n;i++)
	{
		if(*(a+i)  >  *max)
		{
			max = a+i;
		}
	}
	return max;
}

int main()
{
	int a[5] = {2,4,1,57,24};
	int *max,n;
	n = 5;
	max = found_max(a,n);
	printf("max = %d\n",*max);
}
***/

/***拼接字符串
#include<stdio.h>
#include<string.h>


void str1_str2(char *str1,char *str2)
{
	char str1_2[100];
	char *p = str1_2;
//	char *p1,*p2; 
//	int i,j,strl1,strl2;
	printf("***********\n");
	while(*str1 != '\0')
	{
		*p = *str1;
		p++;
		str1++;
	}
	printf("***********\n");
//	printf("合并后的字符串为:%s\n",str1_2);
	while(*str2!='\0')
	{
		*p = *str2;
		p++;
		str2++;
	}
	*p = '\0';

	/*
	for(i = 1;i<=str2;i++)
	{
		*(p1+strl+i) = *(p2+i);
	}
	*(p1+strl+1+i) = '\0';
	while(*str != '\0')
	{
		str1_2 = str1;
		str1_2++;
		str1++;
	}
	str1_2 = '\0';
	*/
	/*
	while(*p1 != '\0')
	{
		*str1_2=*p1;
		str1_2++;
		p1++;
	}
	(str1_2+strl1)++;
	while(*p2 != '\0')
	{
		(str1_2+strl1) = p2;
		(str1_2+strl1)++;
		 p2++;
	}
	++(str1_2+strl1+strl2) = '\0';
	*/
	printf("***********\n");
	printf("合并后的字符串为:%s\n",str1_2);
//	return str1_2; 
//}

/*
int main()
{
	char str1[100];
	char str2[100];
//	char *str3;
	printf("请输入字符串1：\n");
	scanf("%s",str1);
//	printf("%s\n",str1);
	printf("请输入字符串2：\n");
	scanf("%s",str2);
	str1_str2(str1,str2);
//	printf("%s\n",str2);
//	str1_2 = str1_str2(str1,str2);
//	printf("合并后的字符串为:%s\n",*str1_2);
}
*/
/**利用指针对数组进行逆序排列
void reverse_order(int *a,int n)
{
	int i,temp;
	for(i = 0;i < n/2;i++)
	{
		temp = *(a+i);
		*(a+i) = *(a+n-i-1);
		*(a+n-i-1) = temp;
	}
}



int main()
{
	int a[10] = {0,1,2,3,4,5,6,7,8,9};
	int i;
	reverse_order(a,10);
	for(i = 0;i<10;i++)
	{
		printf("%d->",a[i]);	
	}
	
}
**/